package company.tencent;

import java.util.Scanner;

/**
 * @author briarbear
 * @blog https://briarbear.github.io
 * @date 2018-09-16 11:47
 */
public class T4 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {

            int ceilling = 1000010;
            boolean[] prime_num = new boolean[1000010];
            for (int i = 2; i * i  < ceilling; i++) {
                if (!prime_num[i]){
                    for (int j = 2 * i; j < ceilling; j+= i) {
                        prime_num[j] = true;
                    }
                }
            }

            int n = scanner.nextInt();
            int res = 2;
            for (int i = 0; i <= n ; i++) {
                if (!prime_num[i]){
                    int a = (int) (Math.log(n) / Math.log(i));
                    int b = (int) (Math.pow(i,a));
                    for (int j = 2; ; j++) {
                        if (b * j > n){
                            b *= j;
                            break;
                        }
                    }
                    res = Math.max(res,b);
                }
                
            }

            System.out.println(res);
        }
    }
}
